(function(){"use strict";BX.namespace("BX.Landing.UI.Field");var e=BX.Landing.Utils.bind;var i=BX.Landing.Utils.fireCustomEvent;var t=BX.Landing.Utils.getQueryParams;var a=BX.Landing.Utils.remove;var n=BX.Landing.Utils.create;BX.Landing.UI.Field.Embed=function(e){e.textOnly=true;var i=e.content;e.content=i.source||i.src;e.placeholder=BX.Landing.Loc.getMessage("LANDING_EMBED_NOT_BG_FIELD_DESCRIPTION");e.description=e.description||"<span class='landing-ui-anchor-preview'>"+BX.Landing.Loc.getMessage("LANDING_EMBED_NOT_BG_FIELD_DESCRIPTION")+"</span>";BX.Landing.UI.Field.Text.apply(this,arguments);this.hiddenInput=n("input",{props:{type:"hidden",value:i.src||this.input.innerText}});this.error=BX.create("div",{props:{className:"landing-ui-field-error"}});BX.Dom.append(this.error,this.layout);BX.Dom.style(this.description,"margin-bottom","0px");this.adjustForm()};BX.Landing.UI.Field.Embed.isBgVideo=false;BX.Landing.UI.Field.Embed.prototype={constructor:BX.Landing.UI.Field.Embed,__proto__:BX.Landing.UI.Field.Text.prototype,onInputInput:function(){var e=this.getValue();this.adjustForm(true);this.onInputHandler(e);this.onValueChangeHandler(this);var i=new BX.Event.BaseEvent({data:{value:e},compatData:[e]});this.emit("change",i)},isEmbedUrl:function(e){return BX.Landing.Utils.Matchers.youtube.test(e)||BX.Landing.Utils.Matchers.vimeo.test(e)||BX.Landing.Utils.Matchers.rutube.test(e)||BX.Landing.Utils.Matchers.vk.test(e)||BX.Landing.Utils.Matchers.vine.test(e)||BX.Landing.Utils.Matchers.facebookVideos.test(e)},getValue:function(){return{src:this.mediaService?this.mediaService.getEmbedURL():this.input.innerText,preview:this.mediaService?this.mediaService.getEmbedPreview():"",source:this.input.innerText,ratio:this.mediaService&&this.mediaService.isVertical?BX.Landing.Block.Node.Embed.DEFAULT_RATIO_V:BX.Landing.Block.Node.Embed.DEFAULT_RATIO_H}},adjustForm:function(e){var i=String(this.input.innerText).trim();this.hideError();if(this.isEmbedUrl(i)){if(this.mediaService&&this.mediaService.form){a(this.mediaService.form.layout)}const r=new BX.Landing.MediaService.Factory;this.mediaService=r.create(i,!e?t(this.hiddenInput.value):{});this.mediaService.setBgVideoMode(this.constructor.isBgVideo);if(this.mediaService){var n=this.mediaService.getSettingsForm();if(n){this.layout.appendChild(n.layout)}if(!this.mediaService.isDataLoaded){this.readyToSave=false;BX.addCustomEvent(this.mediaService,"onDataLoaded",(()=>{this.readyToSave=true;this.emit("onChangeReadyToSave")}));BX.addCustomEvent(this.mediaService,"onDataLoadError",(e=>{this.readyToSave=false;this.showError(e.message)}))}this.emit("onChangeReadyToSave")}}else{if(this.mediaService){a(this.mediaService.form.layout)}if(BX.Type.isStringFilled(i)){this.showError(BX.Landing.Loc.getMessage("LANDING_EMBED_ERROR_WRONG_SOURCE_TEXT_ALL"))}}},showError:function(e){BX.Dom.append(BX.Landing.UI.Field.BaseField.createError(e),this.error);BX.Dom.style(this.description,"margin-bottom",null)},hideError:function(){BX.Dom.clean(this.error);BX.Dom.style(this.description,"margin-bottom","0px")}}})();
//# sourceMappingURL=embed_field.map.js